const path = require('path');
const VueLoaderPlugin = require("vue-loader/lib/plugin");//编译vue
const HtmlWebpackPlugin = require('html-webpack-plugin'); //打包时动态生成html
const {CleanWebpackPlugin} = require('clean-webpack-plugin');//打包时清除旧资源

module.exports={
    mode: 'production', //指定环境-生成环境
    entry:'./main.js',  //指定打包时的入口文件-main.js
    //指定打包到哪个文件夹那个文件
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'bundle.js',
    },
    //编译模块
    module: {
        rules: [
            {
                test: /\.vue$/,
                loader: "vue-loader",
            },
            {
                test: /\.css$/,
                use:[
                    'style-loader',
                    'css-loader',
                ]
            },
        ],
    },
    //使用插件
    plugins: [
        new CleanWebpackPlugin(),
        new HtmlWebpackPlugin({
            title: '苹果手机旗舰店',
            template:'./src/index.html'
        }),
        new VueLoaderPlugin(),
    ],

    //创建本地服务器
    devServer: {
        contentBase:'./dist', 
        port: 3000,
        open: true,
        hot: true,
        host:"localhost"
    },
}